<?php
/** Physician_list
	* 
	* @package Pharmacy Intervention 
	* @subpackage Controller
	* @category Setup 
	* @author Ray Nowell 
	*/  
class Physician_list extends MY_Controller {

	function Physician_list()
	{
		parent::MY_Controller();
	}
	
	function index()
	{
		define("POPUP_HEIGHT", 300);
		define("POPUP_WIDTH", 800);
		
		$data['title'] = COMPANY_NAME." -- Physician List";
		$data['heading'] = "Physicians";
		
		$data['additional_javascript_doc_ready_functions'] = get_grid_doc_ready_javascript();
		$data['additional_jquery_javascript'] = get_grid_functions('physician', POPUP_HEIGHT, POPUP_WIDTH);
		
		
		$data['add_link'] = '<input id="_gridAddTop" type="image" border="0" language="javascript" onclick="return false;" alt="Insert" title="Insert" src="'.base_url().'images/add.png"  style="cursor: pointer;"/>';
		$data['view_link'] = '<input class="GridButton" id="_gridViewTop" type="image" disabled="disabled" border="0" language="javascript" onclick="return false;" alt="View" title="View" src="'.base_url().'images/view_disabled.png"  style="cursor: pointer;"/>';
		$data['copy_link'] = '<input class="GridButton" id="_gridCopyTop" type="image" disabled="disabled" border="0" language="javascript" onclick="return false;" alt="Copy" title="Copy" src="'.base_url().'images/copy_disabled.png"  style="cursor: pointer;"/>';
		$data['delete_link'] = '<input class="GridButton" id="_gridDeleteTop" type="image" disabled="disabled" border="0" language="javascript" onclick="return false;" alt="Delete" title="Delete" src="'.base_url().'images/delete_disabled.png"  style="cursor: pointer;"/>';

		$this->load->library('table');
		$this->table->set_heading('<input type="checkbox" id="_chkMaster">','Last Name','First Name','Group','Active');
		
		$this->load->model('Physician_model');
		
		//$this->output->enable_profiler(TRUE);	
		$physician_array = $this->Physician_model->get_physician_list();
		
		//loop through the results and hyperlink the id
		foreach($physician_array	as $row)
		{
			$java_script_text	=	'popup_edit_single('.$row['physician_id'].');return false;'; //Must do this before replacing text on line below
			$row['physician_id']= '<input class="GridCheckbox" type="checkbox" name="_chkIntervention'.$row['physician_id'].'" >';
			$edit_link_atts = array('title' => 'Edit',
									'onclick' => $java_script_text 
									);
			$row['last_name'] = anchor('#',$row['last_name'],$edit_link_atts);
			$this->table->add_row($row);
		}
		
		$local_table_template = set_table_template();
		$this->table->set_template($local_table_template); 
		$local_table = $this->table->generate();
		$data['physician_list'] = str_replace('<td><input class="GridCheckbox"','<td class="GridCheckboxTd"><input class="GridCheckbox"',$local_table);
		
		//Check flash data to see if there is any text to display to the user 
		$deleted_info = $this->session->flashdata('deleted_info');
		if (!empty($deleted_info))
			$data['deleted_info']	=	$deleted_info;
		
		$data['view'] = 'physician_list_view';
		$this->load->vars($data);
		$this->load->view('master_view', $data);	
		
		
	}
	
	function SetTableTemplate()
	{
	 $tmpl = array (
										'table_open'					=> '<table class="grid" border="0" cellpadding="4" cellspacing="0">',

										'heading_row_start'	 => '<tr class="gridHeader">',
										'heading_row_end'		 => '</tr>',
										'heading_cell_start'	=> '<th>',
										'heading_cell_end'		=> '</th>',

										'row_start'					 => '<tr>',
										'row_end'						 => '</tr>',
										'cell_start'					=> '<td>',
										'cell_end'						=> '</td>',

										'row_alt_start'			 => '<tr class="gridAlternatingRow">',
										'row_alt_end'				 => '</tr>',
										'cell_alt_start'			=> '<td>',
										'cell_alt_end'				=> '</td>',

										'table_close'				 => '</table>'
							);

		return $tmpl;
	}
	
	function delete()
	{
		$this->output->enable_profiler(TRUE);
		$this->load->model('Physician_model');
		$ret_val	=	$this->Physician_model->Delete_physician();
		
		if (count($ret_val) > 0)
			$this->session->set_flashdata('deleted_info', $ret_val);
		redirect('physician_list');
	}
	
}

/* End of file physician_list.php */
/* Location: ./system/application/controllers/physician_list.php */